package com.math3d;

import java.util.Arrays;

/**
 * @Author: clm
 * @Date: 2018-10-15
 */

public class Vector3fv {
    float vec[] = new float[3];
    public Vector3fv(){
    }
    public Vector3fv(float[] vec) {
        this.vec = vec;
    }
    public Vector3fv(float x, float y, float z) {
        vec[0] = x;
        vec[1] = x;
        vec[2] = x;
    }

    public float[] getVec() {
        return vec;
    }

    public void setVec(float[] vec) {
        this.vec[0] = vec[0];
        this.vec[1] = vec[1];
        this.vec[2] = vec[2];
    }
    public void setVec(float x, float y, float z){
        vec[0] = x;
        vec[1] = y;
        vec[2] = z;
    }

    public static Vector3fv inter(Vector3fv v1, Vector3fv v2, float t){
        float s = 1 - t;
        Vector3fv result = new Vector3fv();
        result.vec[0] = v1.vec[0] * s + v2.vec[0] * t;
        result.vec[1] = v1.vec[1] * s + v2.vec[1] * t;
        result.vec[2] = v1.vec[2] * s + v2.vec[2] * t;
        return result;
    }

    @Override
    public String toString() {
        return "Vector3fv{" +
                "vec=" + Arrays.toString(vec) +
                '}';
    }
}
